#pragma once
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;

#include<cstdlib>
#include<stdio.h>
#include<ctime>

#define SSIZE 100000

void tTest_Stack() {
	stack<string> s;

	clock_t timeStart = clock();
	cout << "开始时间: " << timeStart << endl;
	char buf[10];
	for (int i = 0; i < SSIZE; i++) {
		try {
			snprintf(buf, 10, "%d", rand());	//根据格式化得到字符串
			s.push(buf);
		}
		catch (exception& p) {
			cout << "i= " << i << " " << p.what() << endl;
			abort();	//退出程序
		}
	}

	cout << "stack 赋值所需要时间: " << clock() - timeStart << endl;
	cout << "stack 大小: " << s.size() << endl;
	cout << "stack 顶端元素(栈顶): " << s.top() << endl;
	
	s.pop();	//取出元素 << endl
	cout << "stack pop后大小: " << s.size() << endl;
	cout << "stack pop后顶端元素(栈顶): " << s.top() << endl;
}